package com.baymax.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
import com.baymax.entity.SysUser;
import com.baymax.mapper.SysUserMapper;
import com.baymax.service.SysUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * 用户 服务实现
 *
 * @Author: baymax
 * @CreateTime: 2023/3/28 22:31
 * @Version: 1.0
 */
@Service
@RequiredArgsConstructor
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

    private final BCryptPasswordEncoder passwordEncoder;

    @Override
    public Boolean add(SysUser sysUser) {
        sysUser.setPassword(passwordEncoder.encode(sysUser.getPassword()));
        return SqlHelper.retBool(baseMapper.insert(sysUser));
    }
}
